
#include "DeviceState.h"

using namespace ttg_internal::services;

//-------------------
//--- DeviceState ---
//-------------------

DeviceState::DeviceState(ttg::devices::Device *device, ttg::utils::ParameterSet *owner_filter)
{

	this->device = device;
	device_filter = new ttg::utils::ParameterSet(device->getName(), owner_filter);
	active_task_count = new ttg::utils::Parameter<int>("Executed tasks", device_filter);
	active_task_count->setReadOnly(true);
	*active_task_count = 0;
	available_task_count = new ttg::utils::Parameter<int>("Ready tasks", device_filter);
	available_task_count->setReadOnly(true);
	*active_task_count = 0;
	max_task_count = new ttg::utils::Parameter<int>("Max executed tasks", device_filter);
	max_task_count->setReadOnly(true);
	//<fix_me>
	*max_task_count = (int)device->getAllApis()[0]->getConcurrencyLevel();
	//</fix_me>
}

DeviceState::~DeviceState()
{
	SAFE_DELETE(max_task_count);
	SAFE_DELETE(active_task_count);
	SAFE_DELETE(available_task_count);
	SAFE_DELETE(device_filter);
}
